package com.jahentao.testcase;


import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * 命令行编译指令模板方法<br>
 * 约定获取的配置文件名为config.properties <br>
 * @author jahentao
 * @version 1.0
 * @updated 26-5月-2017 18:02:47
 */

public abstract class CLITemplate {

    /**
     * 配置文件属性读取器
     */
	private Properties properties;

    /**
     * 执行的命令行编译指令
     */
    protected String command;

    /**
     * C++编译器位置
     */
    private final String compiler;

    /**
     * 编译需要的头文件
     */
    private final String[] includes;
    /**
     * 编译需要的库
     */
    private final String[] libs;
    /**
     * 中间文件生成的目录
     */
    private final String outputDir;
    /**
     * 网上找的正确答案源码放的目录
     */
    private final String corrSource;
    /**
     * 我的程序编写源码目录
     */
    private final String mineSource;
    public CLITemplate() throws IOException {
		properties = new Properties();
		properties.load(this.getClass().getResourceAsStream("/config.properties"));
        compiler = properties.getProperty("project.compiler");
        String include = properties.getProperty("project.includes");
        includes = include.split(";");
        String lib = properties.getProperty("porject.libs");
        libs = lib.split(";");
        outputDir = properties.getProperty("project.output.directory");
        corrSource = properties.getProperty("project.correct.sources");
        mineSource = properties.getProperty("project.mine.sources");
    }

	/**
	 * 编译
	 * @param command 命令行编译指令（可以外部指定）对外开放
	 */
	public abstract void compile(String command);

    public String getCommand() {
        return command;
    }

    public String getCompiler() {
        return compiler;
    }

    public String[] getIncludes() {
        return includes;
    }

    public String[] getLibs() {
        return libs;
    }

    public String getOutputDir() {
        return outputDir;
    }

    public String getCorrSource() {
        return corrSource;
    }

    public String getMineSource() {
        return mineSource;
    }

}